package cn.wowjoy.pda.android_pharmacy.mvvm.presenter;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import cn.wowjoy.pda.android_pharmacy.common.core.BasePresenter;
import cn.wowjoy.pda.android_pharmacy.common.utils.MyCompare;
import cn.wowjoy.pda.android_pharmacy.common.utils.PreferenceManager;
import cn.wowjoy.pda.android_pharmacy.model.xmlEntity.doorPatientInfo.DoorPatientInfoBeen;
import cn.wowjoy.pda.android_pharmacy.mvvm.vm.DoorTakeMedicineDetailViewModel;

/**
 * Created by sinyo on 2017/7/20.
 */

public class DoorTakeMedicineDetailPresenter extends BasePresenter<DoorTakeMedicineDetailViewModel> {
    public ArrayList<DoorPatientInfoBeen> FitstData =new ArrayList<>();
   private ArrayList<DoorPatientInfoBeen> mTestBeen=new ArrayList<>();
    public String DJJLID;
    public  String BRDAID;
    public String BRZYID;
    public List<String> DJJLIDs;
    public int type;

    @Override
    public void onCreatePresenter() {
        loadData(false);
    }

    @Override
    public void loadData(boolean ref) {
        FitstData.clear();
         type = activity.getIntent().getIntExtra("type", 0);
        if(type == 1){
            DJJLIDs = (List<String>) activity.getIntent().getExtras().getSerializable("DJJLIDs");
        }else{
            DJJLID=activity.getIntent().getExtras().getString("DJJLID");
        }
        List<DoorPatientInfoBeen> employeeInfoBeenList = (List<DoorPatientInfoBeen>) activity.getIntent().getExtras().getSerializable("doorPatientInfoBeen");

        BRDAID=activity.getIntent().getExtras().getString("BRDAID");
        BRZYID=activity.getIntent().getExtras().getString("BRZYID");
        if(employeeInfoBeenList != null && employeeInfoBeenList.size() != 0){
            PreferenceManager.getInstance().setDoorMedicineProgressTotal(employeeInfoBeenList.size()+"");
//            DoorPatientInfoBeen[] objects = employeeInfoBeenList.toArray(new DoorPatientInfoBeen[0]);
            Collections.sort(employeeInfoBeenList,new MyCompare<DoorPatientInfoBeen>());
            FitstData.addAll(employeeInfoBeenList);
//            Log.e("PXY", "init: "+FitstData.toString() );
            if(FitstData!=null ){
                viewModel.setWData(FitstData);
            }
        }
    }





}
